﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            user.Add("admin", "admin");
        }

        public static Dictionary<string, string> user = new Dictionary<string, string>();

        //登录
        private void button1_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;

            var usr = user.Where(x => x.Key == uid && x.Value == pwd).Select(x => new { key = x.Key, value = x.Value }).FirstOrDefault();

            if (usr!=null)
            {
                MessageBox.Show("登录成功","提示");
                this.Hide();
                MainForm mainForm = new MainForm();
                mainForm.Show();

            }
            else
            {
                MessageBox.Show("用户名或密码错误","提示");
            }
        }

        //注册
        private void button2_Click(object sender, EventArgs e)
        {
            RegisterForm registerForm = new RegisterForm();
            registerForm.Show();
        }
    }
}
